define(function(require){
	var $=require("jq");
	var YY_win=require("/pinzhiV2.0/js/pz_use_dialog.js");
	function ApplyWin(obj){
		var $this=this;
		this.obj$=obj;
		$(".applyHref").click(function(){
			$this.open($(this).attr("data-orderId"));
		});
	}
	ApplyWin.prototype={
		open:function(orderId){
			var $this=this;
			var dialog=new YY_win({
						  type:"confirm",//"confirm",
						  height:300,
						  width:600,
						  text:"订单"+orderId+"的申请",
						  tipsText:"<textarea data-id='"+orderId+"' id='applyText'></textarea>",
						  buttonSureText:"提交", 
						  buttonCancelText:"取消", 
						  callBack:function(){ //回调函数		
								$this.submit($("#applyText").attr("data-id"),$("#applyText").val(),dialog);
								return true;
						  },
						  /*cancelCallBack:function(){
						  },*/
						  mask:0.3,
						  isDrag:true             //开起拖动
						});
			$("#applyText").focus();
		},
		submit:function(orderId,text,dialog){
			$.post("/afterSales/addAfterSales.do",{aliascode:orderId,content:text},function(json){
				if(json.ret==-1){
					new YY_win({
						  type:"tips",//"confirm",
						  width:250,
						  text:json.msg
						});
				}else{
					window.location=window.location;
				}
			},"json");
		}
	}
	var applyWin=new ApplyWin($("#applyWin"));
});